/* ============================================================
   Chatbot FAQ - Estilos del widget
   Personaliza los colores y tamaños modificando las variables
   CSS de abajo (puedes sobrescribirlas en tu propia hoja de estilos).
   ============================================================ */
.cbfaq {
    --cbfaq-primary: #4f46e5;          /* Color principal (botón, encabezado, mensajes del usuario) */
    --cbfaq-primary-dark: #4338ca;     /* Color principal al pasar el mouse */
    --cbfaq-primary-text: #ffffff;     /* Texto sobre el color principal */
    --cbfaq-bg: #ffffff;               /* Fondo de la ventana */
    --cbfaq-messages-bg: #f5f6fa;      /* Fondo del área de mensajes */
    --cbfaq-bot-bubble: #ffffff;       /* Burbuja del bot */
    --cbfaq-bot-text: #1f2937;         /* Texto del bot */
    --cbfaq-border: #e5e7eb;           /* Bordes */
    --cbfaq-muted: #9ca3af;            /* Texto secundario (hora, placeholder) */
    --cbfaq-radius: 16px;              /* Redondeo de la ventana */
    --cbfaq-width: 370px;              /* Ancho de la ventana */
    --cbfaq-height: 560px;             /* Alto máximo de la ventana */
    --cbfaq-offset: 24px;              /* Distancia a los bordes de la pantalla */
    --cbfaq-z-index: 999999;           /* Capa (para quedar por encima de tu sitio) */
    --cbfaq-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    position: fixed;
    right: var(--cbfaq-offset);
    bottom: var(--cbfaq-offset);
    z-index: var(--cbfaq-z-index);
    font-family: var(--cbfaq-font);
    font-size: 15px;
    line-height: 1.45;
}
.cbfaq *, .cbfaq *::before, .cbfaq *::after { box-sizing: border-box; }
.cbfaq--left { right: auto; left: var(--cbfaq-offset); }

/* ---------- Botón flotante ---------- */
.cbfaq-launcher {
    position: relative;
    width: 60px; height: 60px;
    border: none; border-radius: 50%;
    background: var(--cbfaq-primary);
    color: var(--cbfaq-primary-text);
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
    transition: transform .2s ease, background .2s ease;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.cbfaq-launcher:hover { background: var(--cbfaq-primary-dark); transform: scale(1.06); }
.cbfaq-launcher:focus-visible { outline: 3px solid rgba(79, 70, 229, .4); outline-offset: 3px; }
.cbfaq-launcher__icon {
    position: absolute; display: flex;
    transition: opacity .2s ease, transform .3s ease;
}
.cbfaq-launcher svg { width: 28px; height: 28px; fill: currentColor; }
.cbfaq-launcher__icon--close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.cbfaq--open .cbfaq-launcher__icon--chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.cbfaq--open .cbfaq-launcher__icon--close { opacity: 1; transform: none; }

/* ---------- Ventana de chat ---------- */
.cbfaq-window {
    position: absolute;
    right: 0; bottom: 76px;
    width: var(--cbfaq-width);
    height: min(var(--cbfaq-height), calc(100vh - 120px));
    display: flex; flex-direction: column;
    background: var(--cbfaq-bg);
    border-radius: var(--cbfaq-radius);
    box-shadow: 0 16px 48px rgba(0, 0, 0, .18);
    overflow: hidden;
    /* Estado cerrado: invisible y ligeramente desplazada (animación) */
    opacity: 0; visibility: hidden;
    transform: translateY(16px) scale(.96);
    transform-origin: bottom right;
    transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
}
.cbfaq--left .cbfaq-window { right: auto; left: 0; transform-origin: bottom left; }
.cbfaq--open .cbfaq-window {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity .25s ease, transform .25s ease, visibility 0s;
}

/* ---------- Encabezado ---------- */
.cbfaq-header {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    background: var(--cbfaq-primary);
    color: var(--cbfaq-primary-text);
}
.cbfaq-header__avatar {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 50%; background: rgba(255, 255, 255, .2);
    display: flex; align-items: center; justify-content: center;
}
.cbfaq-header__avatar svg { width: 22px; height: 22px; fill: currentColor; }
.cbfaq-header__info { flex: 1; min-width: 0; }
.cbfaq-header__title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbfaq-header__subtitle { font-size: 12.5px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.cbfaq-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; }
.cbfaq-header__close {
    width: 34px; height: 34px; border: none; border-radius: 50%;
    background: transparent; color: inherit; cursor: pointer;
    display: flex; align-items: center; justify-content: center; padding: 0;
    transition: background .2s ease;
}
.cbfaq-header__close:hover { background: rgba(255, 255, 255, .18); }
.cbfaq-header__close svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Área de mensajes ---------- */
.cbfaq-messages {
    flex: 1; overflow-y: auto;
    padding: 16px;
    background: var(--cbfaq-messages-bg);
    display: flex; flex-direction: column; gap: 10px;
    scroll-behavior: smooth;
}
.cbfaq-msg { display: flex; flex-direction: column; max-width: 82%; animation: cbfaq-pop .25s ease; }
.cbfaq-msg--bot { align-self: flex-start; align-items: flex-start; }
.cbfaq-msg--user { align-self: flex-end; align-items: flex-end; }
.cbfaq-msg__bubble {
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word; overflow-wrap: anywhere;
}
.cbfaq-msg--bot .cbfaq-msg__bubble {
    background: var(--cbfaq-bot-bubble); color: var(--cbfaq-bot-text);
    border: 1px solid var(--cbfaq-border);
    border-bottom-left-radius: 4px;
}
.cbfaq-msg--user .cbfaq-msg__bubble {
    background: var(--cbfaq-primary); color: var(--cbfaq-primary-text);
    border-bottom-right-radius: 4px;
}
.cbfaq-msg__bubble a { color: inherit; text-decoration: underline; }
.cbfaq-msg--bot .cbfaq-msg__bubble a { color: var(--cbfaq-primary); }
.cbfaq-msg__time { font-size: 11px; color: var(--cbfaq-muted); margin-top: 3px; padding: 0 4px; }

/* Indicador "escribiendo..." */
.cbfaq-typing .cbfaq-msg__bubble { display: flex; gap: 4px; padding: 14px 16px; }
.cbfaq-typing__dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--cbfaq-muted);
    animation: cbfaq-bounce 1.2s infinite ease-in-out;
}
.cbfaq-typing__dot:nth-child(2) { animation-delay: .15s; }
.cbfaq-typing__dot:nth-child(3) { animation-delay: .3s; }

/* Sugerencias rápidas */
.cbfaq-chips { display: flex; flex-wrap: wrap; gap: 6px; animation: cbfaq-pop .25s ease; }
.cbfaq-chip {
    border: 1px solid var(--cbfaq-primary);
    background: var(--cbfaq-bg); color: var(--cbfaq-primary);
    border-radius: 999px; padding: 6px 12px;
    font: inherit; font-size: 13px; cursor: pointer;
    transition: background .2s ease, color .2s ease;
}
.cbfaq-chip:hover { background: var(--cbfaq-primary); color: var(--cbfaq-primary-text); }

/* ---------- Campo de entrada ---------- */
.cbfaq-input {
    display: flex; align-items: center; gap: 8px;
    padding: 12px; margin: 0;
    border-top: 1px solid var(--cbfaq-border);
    background: var(--cbfaq-bg);
}
.cbfaq-input__field {
    flex: 1; min-width: 0;
    border: 1px solid var(--cbfaq-border); border-radius: 999px;
    padding: 10px 16px;
    font: inherit; font-size: 16px; /* 16px evita el zoom automático en iOS */
    color: var(--cbfaq-bot-text); background: var(--cbfaq-bg);
    outline: none; transition: border-color .2s ease;
}
.cbfaq-input__field:focus { border-color: var(--cbfaq-primary); }
.cbfaq-input__field::placeholder { color: var(--cbfaq-muted); }
.cbfaq-input__send {
    width: 42px; height: 42px; flex-shrink: 0;
    border: none; border-radius: 50%;
    background: var(--cbfaq-primary); color: var(--cbfaq-primary-text);
    cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s ease, opacity .2s ease;
}
.cbfaq-input__send:hover { background: var(--cbfaq-primary-dark); }
.cbfaq-input__send:disabled { opacity: .5; cursor: not-allowed; }
.cbfaq-input__send svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Animaciones ---------- */
@keyframes cbfaq-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cbfaq-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

/* ---------- Responsive (móvil): la ventana ocupa toda la pantalla ---------- */
@media (max-width: 480px) {
    .cbfaq { right: 16px; bottom: 16px; }
    .cbfaq--left { left: 16px; }
    .cbfaq-window {
        position: fixed; inset: 0;
        width: 100%; height: 100%;
        border-radius: 0;
    }
    .cbfaq--open .cbfaq-launcher { display: none; } /* Se cierra con la X del encabezado */
    .cbfaq-msg { max-width: 88%; }
}

/* Respeta la preferencia de "reducir movimiento" del sistema */
@media (prefers-reduced-motion: reduce) {
    .cbfaq *, .cbfaq *::before, .cbfaq *::after { animation: none !important; transition: none !important; }
}
